Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gnovm): enforce size of int and uint to 64 bits on all arch. #3591

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mvertes
Copy link
Contributor

@mvertes mvertes commented Jan 23, 2025

With these changes, int and uint are always represented in gnovm as int64 and uint64 whatever the underlying hardware architecture.

There should be no change for 64 bits platforms. On other (unsupported) platforms, int and uint will be 64 bits instead of hardware size.

Fixes #3288.

With these changes, `int` and `uint` are always represented in
gnovm as `int64` and `uint64` whatever the underlying hardware
architecture.

There should be no change for 64 bits platforms. On other
(unsupported) platforms, `int` and `uint` will be 64 bits
instead of hardware size.

Fixes gnolang#3288.
@mvertes mvertes self-assigned this Jan 23, 2025
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Jan 23, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 23, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: mvertes/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Jan 23, 2025
Copy link

codecov bot commented Jan 23, 2025

@thehowl thehowl self-requested a review January 23, 2025 15:25
l := big.NewInt(int64(lv.GetInt()))
r := big.NewInt(0).Lsh(l, rv.GetUint())
l := big.NewInt(lv.GetInt())
r := big.NewInt(0).Lsh(l, uint(rv.GetUint()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for these cases, where we don't work on Bigint types, it may be useful to just use min(rv.GetUint(), 64), as all operations beyond 64 behave the same and would return 0 anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should have a different implementation of operators, one for the general var case, fast and not relying on bigints, and the other for constants, slower using bigints. This is a deep change, not for this PR.

gnovm/pkg/gnolang/op_exec.go Outdated Show resolved Hide resolved
@@ -91,15 +91,15 @@ func (m *Machine) doOpSlice() {
var lowVal, highVal, maxVal int = -1, -1, -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These come from the user, could they not be int64?

@Kouteki Kouteki added this to the 🚀 Mainnet beta launch milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Do not use bitsize-dependent values in the GnoVM
4 participants